using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using Instedd.Labs.Geo.Library.Sms;

public partial class EditSendNameLookupTable : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (StreamReader reader = new StreamReader(SmsManager.GetManager().SenderNameLookupProvider.Stream))
            {
                this.TextBoxTableContent.Text = reader.ReadToEnd();
            }
        }
    }

    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        SmsManager.GetManager().SenderNameLookupProvider.Reset();
        using (StreamWriter writer = new StreamWriter(SmsManager.GetManager().SenderNameLookupProvider.Stream))
        {
            writer.Write(this.TextBoxTableContent.Text);
        }

        SmsManager.GetManager().SenderNameLookupProvider.Refresh();
        SmsManager.GetManager().GenerateKml();
        SmsManager.GetManager().GenerateGeoRss();
        GoToHome();
    }

    protected void ButtonCancel_Click(object sender, EventArgs e)
    {
        GoToHome();
    }

    private void GoToHome()
    {
        Response.Redirect("Home.aspx");
    }
}
